{"componentChunkName":"component---src-templates-blog-post-js","path":"/functions in js/","webpackCompilationHash":"fbb20c27e610daab547e","result":{"data":{"site":{"siteMetadata":{"title":"Articles","author":"Aman-Sharma"}},"markdownRemark":{"id":"186e0955-802f-5e79-806c-dcb2e8b8c299","excerpt":"what is function Function is the set or collection of instructions which are kept in the box called function.which when we executes it pefroms a specific task…","html":"<h2>what is function</h2>\n<p>Function is the set or collection of instructions which are kept in the box called function.which when we executes it pefroms a specific task as its output..</p>\n<h2>Types of Functions In JavaScript</h2>\n<ol>\n<li>\n<h2>Named Function</h2>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token function\">sum</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">a<span class=\"token punctuation\">,</span>b</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n<span class=\"token keyword\">return</span> a<span class=\"token operator\">+</span>b<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p><em>Named function means that function declaration with name eg i have given name to function above is sum</em></p>\n</li>\n<li>\n<h2>Anonymous Functions</h2>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">var</span> <span class=\"token function-variable function\">sum</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">function</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">a<span class=\"token punctuation\">,</span>b</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n<span class=\"token keyword\">return</span> a<span class=\"token operator\">+</span>b<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p><em>Anonymous Function or function expression means function without name</em></p>\n</li>\n<li>\n<h2>Immediately invoked function expression (IIFE)</h2>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">a<span class=\"token punctuation\">,</span>b</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n<span class=\"token keyword\">return</span> a<span class=\"token operator\">+</span>b<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">,</span>b<span class=\"token punctuation\">)</span></code></pre></div>\n<p><em>An IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined.</em></p>\n</li>\n<li>\n<h2>Function Execution Or Invocation</h2>\n<p><em>It simply means that the giving command to function for executing the collection of code which we have put inside it</em></p>\n</li>\n</ol>\n<p> <em>for example:</em>\nHere im executing the one of function which i have defined above</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token function\">sum</span><span class=\"token punctuation\">(</span><span class=\"token number\">1</span><span class=\"token punctuation\">,</span><span class=\"token number\">2</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p> *we can execute the function by its name i have provide arguments inside the brackets at time of execution so the output will be <strong>3</strong>.the provided agruments will go inside the parameters which i define above in the function declaration.*</p>\n<ol start=\"5\">\n<li>\n<h2>Different Components Of Functions</h2>\n<p><strong>Genrelly The Main Components Of The Functions Are</strong></p>\n</li>\n<li><em>Function Keyword</em></li>\n<li><em>Function Name</em></li>\n<li><em>Parameters Of The Function</em></li>\n<li><em>Return Statement in The Function If Not Provided It Will Going To Return The Undefined</em></li>\n<li><em>Arguments In The Function at Execution Time</em></li>\n</ol>","frontmatter":{"title":"Functions in js","date":"September 04, 2019","description":"Complete Particulars About The Functions in JavaScript "}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"/functions in js/","previous":null,"next":{"fields":{"slug":"/dataTpes in js/"},"frontmatter":{"title":"DataTypes in javaScript"}}}}}